home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Text Processing
/
BBEdit 2.5 Demo
/
BBEdit Demo QuickStart
< prev
next >
Wrap
Text File
|
1994-02-10
|
61KB
|
1,257 lines
Introduction
Installation
Creating and Saving Documents
Editing Documents
More on Wrapping
Browsers
Printing
Searching
Multi-File Searching
Using BBEdit With THINK C 6.0
Using BBEdit with ToolServer
BBEdit and XTND
Introduction
This document serves as a “Quick Start” guide for using the BBEdit demo.
Some of BBEdit’s capabilities (such as the glossary, Compare, extensions,
XTND translation, etc.) are not covered in this document; we encourage
you to explore. The production BBEdit package includes a 168-page printed
manual, which describes BBEdit’s capabilities in excruciating detail.
Installation
BBEdit consists of the following major components:
• The BBEdit application itself
• The “BBEdit Extensions” folder
• MPW Shell tools and scripts required to support ToolServer
Only the BBEdit application file is required to use BBEdit. All other components
can be installed, or not, at your discretion.
If you’re planning to install the whole set of BBEdit files, create a “BBEdit Folder”.
Copy the BBEdit application, the “BBEdit BBalloons” file (if you’re using System 7),
and the “BBEdit Extensions” folder into your BBEdit Folder.
---
When you launch BBEdit for the first time, it will automatically open a
Disk Browser window. To change BBEdit’s behavior at startup, choose
“Preferences...” from the Edit menu, and click the radio button which
corresponds to what you’d like BBEdit to do. (If you launch BBEdit by
double-clicking on one of its documents, then this setting is ignored, and
BBEdit will just open the document(s) you double-clicked.)
If you’re using BBEdit as an external editor for the THINK Project Manager, we
recommend that you set the startup preference to “Nothing”, for smoothest
operation.
---
Creating and Saving Documents
To create a new document within BBEdit, choose “New” from the File menu. An
empty editing window will be opened on the screen. You can type in this window,
paste text from another document or application, or do anything else which
causes text to be placed in this window.
If you’re using System 6 or System 7, you can use the Finder to open files
created by BBEdit by double-clicking on them.
BBEdit Demo will allow you to manipulate files using any of the commands
available in the full, commercial version of BBEdit; however, it will not allow
you to save your work. Demo versions often include various limitations in order
to encourage you to purchase the software after giving you the opportunity to
try out its features. The most common limitations are to have the program
expire after a certain amount of time, or to remove the ability to save your
work. These prevent you from using the demo program in lieu of the commercial
software they are intended to promote. Time limits make distributing the demo
software difficult, since the software might expire by the time it actually
reaches a potential customer. Thus, we have opted to remove the “Save” feature.
---
Editing Documents
In terms of its basic editing functionality, BBEdit behaves like any other word
processor or text editor on the Macintosh: any typed characters are inserted at
the insertion point; if there is a selection present, the selection is replaced
by the first typed character, and the insertion point is placed after the first
typed character.
The insertion point is indicated by a blinking vertical bar.
If there is any text selected in the active (or front) window, it is highlighted
using your Mac’s default highlight color. If there is text selected in a window
that is inactive (not the front window), it is framed in the highlight color.
As you type, BBEdit scrolls the window’s contents so that the insertion point is
visible. Note that since BBEdit doesn’t automatically wrap the text as you type
(unless you have selected “Wrap While Typing” from the options or preferences
dialogs), the window may scroll horizontally.
To move text from one place to another, select the text you wish to move, and
choose the “Cut” command from the Edit menu. The selected text will be deleted,
and placed in a special area called the “Clipboard”. (The Clipboard always
contains the last text that you cut or copied.) You can then use the “Paste”
command on the Edit menu to place the text elsewhere in the document you’re
editing, or even in another window altogether. Also, any text that you cut or
copy can be pasted into another application. You can place text in the Clipboard
without deleting it by choosing “Copy” from the Edit menu.
When you Paste, the text that’s in the Clipboard will replace the current
selection (if there is one), or be inserted at the insertion point. Paste
doesn’t remove text from the Clipboard, so you can Paste as many times as you
wish.
To delete selected text, hit the “Delete” key on your keyboard, or choose
“Clear” from the Edit menu. If you have a keyboard with a numeric keypad on it,
you can hit the “Clear” key on the keypad to delete the selected text.
To select all the text in the front editing window, choose “Select All” from the
Edit menu. You can then cut, copy, or perform any other action that affects
selected text.
BBEdit provides an assortment of facilities for transforming text in various
ways. The commands to transform text are all found under the Text menu:
• Balance locates the pair of parentheses, braces, or brackets which encloses
the current selection range or insertion point. If there are unmatched
parentheses, braces, or brackets, BBEdit will beep.
• Twiddle transposes the two characters on either side of the insertion
point, or at either end of the selected text.
Note: If you hold down the Option key, Twiddle becomes Twiddle Words. Twiddle
Words behaves in similar fashion to Twiddle, except that it acts on entire
words, rather than individual characters.
• Change Case… allows you to automatically switch between upper and lower
case characters for entire words, first letters of words, or first letters of lines.
• Shift Left and Shift Right indent the selected text by one tab stop (in the
case of Shift Left), or outdent by one tab stop (for Shift Right). If you hold
down the Shift key while choosing one of these commands, the selected text will
be indented or outdented by one space instead of one tab stop.
• The Wrap… command is used for wrapping long lines of text and filling
paragraphs. Essentially, it uses carriage returns to break lines of text, to
keep them from running off to the right of your screen.
• Unwrap… removes carriage returns and spaces between groups of text.
Essentially, it performs the reverse function of the “Wrap…” command.
• Zap Gremlins… is useful for finding and altering non-printing characters
in your text files.
• Entab converts runs of spaces into tabs, according to the current setting in
the “Font and Tabs…” dialog. This transformation is useful when downloading
text from a mainframe computer or on-line service which uses spaces to line up
columns of text; when displaying the text in a monospaced font, columns will
still usually not line up unless you Entab the text.
• Detab converts tabs into runs of spaces, according to the current setting in
the “Font and Tabs…” dialog. This is useful when uploading text to a mainframe
or on-line service which has no concept of tabs as column separators.
---
More on Wrapping
BBEdit offers the capability to wrap text in a variety of ways. This wrapping is
not the “live” word wrapping that word-processors provide; instead, it is useful
when importing text files from word processors or other programs that do not use
carriage returns to break lines on the screen. When opened, such files appear to
have only a few lines in them, which run far past the right-hand edge of the
window.
To wrap text in the current document window, choose “Wrap…” from the Text menu.
The controls on the left half of the “Wrap…” dialog box control how much of the
text is wrapped, and the maximum length of the lines after wrapping.
The group of radio buttons controls the length of lines after they have been
wrapped:
• The “Philip Bar” button will break lines of text at the philip bar. (To see
the location of the philip bar, turn on “Show Philip Bar” in the Windows section
of the Preferences dialog.) The philip bar indicates the maximum usable width of
a document window when the window is zoomed to full size on a nine-inch
“classic” Macintosh screen. For this reason, you’re guaranteed that text wrapped
to the philip bar will be readable without horizontal scrolling by anyone on any
Macintosh.
• If “Window Width” is selected, no wrapped line will be longer than the
current width of the window. This option is useful if you’d like the lines to be
alittle longer or a little shorter than is provided for by the philip bar; just
size the window appropriately and wrap.
• If “Character Width” is selected, the number in the text field designates
the maximum number of characters allowed on any line; a line that exceeds this
number of characters in length will be wrapped. The “Character Width” setting is
useful for preparing postings to on-line services, which can break lines in an
unattractive fashion if they’re longer than a fixed number of characters
(usually 80).
The controls on the right half of the dialog control paragraph wrapping. If the
“Paragraph Fill” check box is turned off, long lines will be wrapped. Short
lines will be left untouched.
---
Browsers
All of the browser windows that you can create in BBEdit have some common
characteristics:
• The Status Area. This section of the browser window contains an “Open”
button, so that you can open the file that is selected in the file list. The
glossary browser contains additional buttons, and disk browser contains other
controls as well.
• The File List. This portion of the window contains a list of the files
currently available for that particular browser. In glossary and disk browsers,
the area that the file list occupies is split in two, and contains both the
directory list and the file list. In a project browser, the file list contains
the files contained in the project that you’re browsing. In a Search Results
browser, the file list also describes the line number and context for a
multi-file search match, and in the Compile Errors window, the file list also
contains the error messages. In both the Search Results and Compile Errors
windows, a file’s name may appear more than once in the file list.
If you click once on an entry in the file list, the file’s text will appear in
the text view. If you double-click on an entry in the file list, BBEdit will
open the file you clicked on; you can also achieve this effect by selecting an
entry and then clicking the “Open” button, or hitting the Return or Enter key.
Each entry in the file list contains the name of the file and the icon that the
finder uses to identify it. You can suppress the icons (and make more room
available in the file list) by un-checking the “Show Icons in Browsers”
check box in the “Browsers” section of the Preferences dialog.
Note: When running under System 6, the icons in browsers are always suppressed.
• The Splitter. The splitter is outlined by a closely-spaced pair of
horizontal lines. When you move the mouse over the splitter, the cursor changes
to a splitter cursor; by clicking and dragging, you can change the relative
sizes of the file list and the text view.
• The Text View. This section of the browser contains the text of the file
that is selected in the file list. You can make a file visible in the text view
by clicking on its entry in the file list. In the case of Search Results and
Compile Errors browsers, the appropriate text will be automatically selected in
the text view whenever you click on an entry in the file list.
Typing and the Active View
Each browser window contains two or more sections; within each section, you can
type (for glossary and disk browsers) or use the arrow keys to navigate the file
list and open files, or use the arrow keys and the “special” keys on the
extended keyboard to navigate the text in the text view. Because typing may have
a different meaning depending on which view is active, and because you have
multiple views available, BBEdit maintains an “active view” for each browser
window. When a specific view is active, it is outlined by a heavy black border,
and all keyboard input is directed to that pane.
When you use the arrow and special-function keys in the text pane of a browser,
they behave just as they do in a normal editing window.
Note: When the text view is active, it is not outlined; you’ll know that this
view is active because none of the views has a heavy border. It’s done this way
for cosmetic reasons.
---
Printing
BBEdit offers a variety of options for varying your printed output. These
options are available from the dialog that appears when you choose “Print…”
from the File menu:
The portion of the dialog above the gray line is the normal set of controls that
is provided by whichever printer driver you use. Below the gray line are
controls provided specifically by BBEdit.
• The “Printing Font:” button will bring up a dialog that allows you to
set the font, size, style, and tab attributes for the text when it’s printed (as
opposed to when it’s displayed). For a description of the controls in this
dialog, see the “Editing” section of this document.
• Check the “Use Document’s Font” checkbox to automatically select the
display font for printing.
• The “Options…” button will present a dialog box for setting various
formatting options, most of which should be self-explanatory.
Most of the options in “Options…” dialog only affect the appearance of the pages that
are printed out, and can therefore be set according to your individual taste.
---
Searching
BBEdit’s gives you the ability to search for strings of characters within the
current document, or within multiple files, whether they’re currently open in
BBEdit or not. When you choose “Find…” from the Search menu, BBEdit will present
a dialog box with several options.
The edit field to the right of “Search For:” contains the string of characters
that you wish to search for. If the “Grep” check box is checked, the string in
this edit field is a regular expression. See below for more information on grep
searching.
The edit field to the right of “Replace With:” contains the string of characters
that will replace the current selection whenever you choose “Replace”, “Replace
and Find Again”, or “Replace All” from the Search menu.
The “Match Case” check box determines whether the search is case-sensitive or
not. If “Match Case” is checked, only text which has the same combination of
upper and lower case letters as the Search For string will be found.
The “Entire Word” check box determines whether the text being searched must be
bounded by word breaks (spaces, dashes, and other punctuation).
The “Wrap Around” check box will cause the entire document to be searched,
regardless of where the current insertion point or selection range lies.
Ordinarily, only the text from the start of the selection range to the end of
the document is searched. If “Wrap Around” is turned on, and the search string
isn’t found between the start of the selection range and the end of the
document, the search will automatically restart from the beginning of the
document. If the search string is found in the document after wrapping around,
BBEdit will blink the menu bar to alert you.
If the “Search Backwards” check box is checked, BBEdit will search backwards
from the start of the insertion point to the start of the document, rather than
forward to the end of the document. If “Wrap Around” is checked, and the search
string is not found between the start of the document and the start of the
selection range, the backwards search will resume from the end of the document.
Activating the “Extend Selection” checkbox tells BBEdit not only to find the
next occurrence of the search string, but to also select all of the text between
the cursor or the selected text and the found string. For example, if you have
typed in the text “The quick brown fox jumps over the lazy dog,” and place the
cursor just before the letter ‘q’, and then search for the string “over,” BBEdit
will highlight “quick brown fox jumps over”.
Note: Unlike many word processors, BBEdit does not just search selected text;
but, rather, the entire document, using the selected text or cursor location as
a starting point.
After you have entered the search and replace strings and set the search options
appropriately, you can click “Find”, “Don’t Find”, or “Cancel”. If you click
“Find”, BBEdit will immediately search for the current search and replace
strings, using the current search options. If you click “Don’t Find”, BBEdit
will accept the current search strings and options, but will not perform the
search; you can then choose “Find Again” from the Search menu to start the
search.
Note: You may click on the key icon to the left of the cancel button to retract
the lower portion of the “Find” dialog box.
---
Multi-File Searching
BBEdit also provides a variety of means for searching through multiple text
files at one time in order to locate the search string. To perform a multi-file
search, check the “Multi-File Search” check box in the Find… dialog.
When you turn on “Multi-File Search”, the “Options…” button is enabled; to set
up the options for a multi-file search, click this button, and a new dialog box
will appear.
The popup menu next to “Search Method” in this dialog box determines how BBEdit
will locate the files to be searched.
There are five ways to locate files:
• On Location™. If you have On Location 2.0 installed in your system, BBEdit
will use On Location to search through all of the files that it knows about, and
return to BBEdit all files which contain the search string. By default, BBEdit
will search through all available On Location index files; you can select a
single index to search from the “Search Index:” popup menu.
• Directory Search. When this search method is chosen, BBEdit scans through
the folders starting at the one you choose, and each file that it encounters
will be searched for the search string.
• Open Windows. When you choose this search method, BBEdit searches for the
search string only in document windows that are currently open. This sort of
search is very fast, and may be most convenient if you wish to limit the scope
of your search to a few files.
• Search Results. This search method is only available when the “Search
Results” window is open and contains the results of a previous Batch Find (see
below).
• Search Project. Use this option to instruct BBEdit to search through files
listed in a particular THINK C or THINK Pascal project. Use the “Set…” button to
choose the project you wish to search.
The check boxes in the “Options…” dialog can be used to tailor the search to
your needs:
• Batch Find accumulates the results of the search in progress and display
them all at once in a Search Results window. If this check box is not checked,
then the multi-file search will stop each time it encounters a match, and open
the file that contains the match.
Once the Search Results window is opened, you can double-click on entries in the
window to display any given match, or select multiple matches from different
files and display them all at once.
• Search Nested Folders causes the Directory Scan search to search folders
which are enclosed in the search’s starting directory. If this check box is
turned off, only the files in the starting directory will be searched.
• Skip (…) Folders causes the Directory Scan to skip folders whose names are
enclosed in parentheses. This is useful if you have folders containing text
files that you do not want to search for one reason or another; just enclose the
folders’ names in parentheses, and they will be skipped.
• Search All File Types. If this check box is checked, BBEdit searches files
of all kinds, regardless of whether they contain actual text or not. If it’s not
checked, only text files will be searched.
• Match File Name. Use this option to search for documents with a file name
that matches a particular string. Your string may use wildcards, with *
representing any run of zero or more characters, and ? representing a wildcard
for one character only. So, for example, a search string of “Chapter 1?” will
match “Chapter 10”, “Chapter 11”, and “Chapter 12”, but not “Chapter 127”.
“Tr*s” could match “Treats”, “Trees” and “Tractor Pulls”.
After you have set the options, click “OK” to save the settings and return to
the “Find…” dialog. If you then click “Find”, the multi-file search will start.
If you click “Don’t Find”, the current settings will be saved, but the
multi-file search won’t start until you choose “Find in Next File” from the
Search menu. (If Batch Find is selected, the “Don’t Find” button is disabled.)
When BBEdit performs a multi-file search, it does so in two steps. First, it
constructs a list of the files to be searched, using the search method specified
in the Multi-File Search Options dialog. Second, it searches each file in the
list for the search string. If “Batch Find” is selected, all occurrences in each
file will be displayed in the Search Results window. Otherwise, each file will
be opened to display the first occurrence of the search string; you can find
subsequent occurrences of the search string in the same file by choosing “Find
Again” from the Search menu. If you’re not using Batch Find, you can locate the
next file that contains the search string by choosing “Find In Next File” from
the Search menu.
You can combine the capabilities of BBEdit’s multi-file search with the Replace
All command to perform multi-file replace operations. To do this, set up a
multi-file search as desired, and un-check the “Batch Find” check box. When you
return to the “Find…” dialog, click “Don’t Find”, and then choose “Find &
Replace All Matches…” from the Search menu. You’ll see the following dialog:
This dialog controls the behavior of a multi-file replace operation. There are
three levels of safety that are available:
• Safest. Click on the “Leave Open” radio button. For each file that
contains the search string, BBEdit will perform a “Replace All” on that file,
and leave the file open so that you can inspect the changes.
• Less Safe. Click on the “Save To Disk” radio button, and make sure that
the “Confirm Saves” check box is checked. BBEdit will perform a replace all on
each file that contains the search string, and then ask you what to do.
If you click “Save”, BBEdit will save the changed file. If you click “Don’t
Save”, BBEdit will throw away the changes that were just performed. If you click
“Leave Open”, BBEdit will leave the file open; this is the same behavior as the
“Safest” case, above. If you click “Cancel Search”, BBEdit will stop the
multi-file replace operation.
• Living on the Edge. Click on the “Save to Disk” radio button, and un-check
the “Confirm Saves” check box. If you do this, BBEdit will perform a Replace All
on each file that contains the search string, and then save the changed file to
disk without asking. You should only use these settings if you’re absolutely
certain of what you’re doing, since the changes are irreversible.
---
Grep Searching
Grep is a method of pattern matching that derives from the Unix™ operating
system. You are probably familiar with simple pattern matching from using word
processors; when you ask a word processor to find all instances of the word
"black", it is performing a simple pattern match, where each letter has to match
literally. Matching strings in this manner is not very hard.
The ability to match strings in a more general manner is both more powerful and
more complicated. It allows for sophisticated pattern matching operations, such
as matching all words that begin with the letter "P" and end with the letters
"er", or deleting the first word of every line. Grep provides a powerful means
of doing this.
To use Grep for searching documents, just check the “Grep” check box in the
Find… dialog.
The popup menu next to the “Patterns:” in the dialog contains a list of your
most commonly-used Grep patterns. You can change this list in the “Grep
Patterns” section of the Preferences… dialog.
How Grep Works
The “grep” mode of searching and replacing is a powerful tool. Although somewhat
slower than normal text searching, grep allows the user to search for one of a
set of many strings instead of a particular string. As a simple example, you
can search for any occurrence of an identifier beginning with the letter P, or
all lines that begin with a left brace.
A pattern is a string of characters that, in turn, describes a set of strings of
characters. An example of a set of strings is the set of all strings that begin
with the letter P and end with the letter r; the strings “Ptr” and “ProcPtr are
members of this set. We say that a string is matched by a pattern if it is
amember of the set described by the pattern. Patterns are composed of
sub-patterns which are patterns in themselves; this is how complicated patterns
may be formed.
The following section goes through the grep pattern matching and replacement
rules step by step, so that by the end of it you should be able to understand
how each of these grep patterns works and be able to make your own.
In some cases, the state of case sensitivity affects the results of a pattern
match. We have noted below when this is the case.
1. Any character, with certain exceptions described below, is a pattern that
matches itself.
2. A pattern x followed by a pattern y forms a pattern xy that matches any
string ßµ where ß can be matched by x and µ can be matched by y. We can, of
course, take the compound pattern xy and concatenate yet another pattern z onto
it, forming the pattern xyz.
3. The character . is a pattern that will match any character.
4. The character \ followed by any character except one of the digits 1-9 is
a pattern that matches that character. (You would use this to find special
characters, such as the . character. To search for a period, you would use \.).
5. A string of characters s surrounded by square brackets ([ and a ]) forms a
pattern [s] that matches a single instance of one of the characters in the
string s. Note that the case sensitivity flag does not apply to characters
between square brackets: letters must match exactly.
5a. The pattern [^ß] matches any character that is not in the string ß.
Special characters will be taken literally in this context. Again, case
sensitivity doesn't apply to characters between square brackets.
5b. If a string of three characters in the form [a-b] occurs in the pattern
p, this represents all of the characters from a to b inclusive. All special
characters are taken literally; i.e., [!-.] denotes the characters from ! to ..
Notice that the only way to include the character ] in p is to make it the very
first character. Likewise, the only way to include the character - in p is to
have it either at the very beginning or the very end of p. Single characters
and ranges may both be used between brackets.
6a. Any pattern p formed by any combination of rules 1 or 3-5b followed by a
* forms the pattern p* that matches zero or more consecutive occurrences of
characters matched by p.
6b. Any pattern p formed by any combination of rules 1 or 3-5b followed by a
+ forms the pattern p+ that matches one or more consecutive occurrences of
characters matched by p.
6c. Any pattern p formed by any combination of rules 1 or 3-5b followed by a
? forms the pattern p? that matches zero or one consecutive occurrences of
characters matched by p.
We now have the ability to form patterns that are composed of sub-patterns, and
will find it useful to "remember" sub-strings matched by sub-patterns and to be
able to match against those substrings.
7. A pattern surrounded by ( and ) is a pattern that matches whatever the
sub-pattern matches. This is useful for matching two or more instances of the
same string and when doing replacements.
8. A \ followed by n, where n is one of the digits 1-9, is a pattern that
matches whatever was matched by the sub-pattern beginning with the "nth"
occurrence of (. A pattern \n may be followed by an *, and forms a pattern \n*
that matches zero or more occurrences of whatever \n matches.
Sometimes it is useful to be able to "constrain" patterns to match only if
certain conditions in the context outside the string matched are met.
9. A pattern p that is preceded by a ^ forms a pattern ^p. If the pattern ^p
is not preceded by any other pattern, it matches whatever p matches as long as
the first character matched by p occurs at the beginning of a line. If the
pattern ^p is preceded by another pattern, then the ^ is taken literally.
10. A pattern p that is followed by a $ forms a pattern p$. If the pattern
p$ is not followed by any other pattern, it matches whatever p matches as long
as the last character matched by p occurs at the end of a line. If the pattern
p$ is followed by another pattern, then the $ is taken literally.
Note that the characters ^ and $ constrain pattern matches to begin or end at
line boundaries, and so can be combined to constrain a pattern to match an
entire line only (as in the above example).
Grep provides not only a more sophisticated method of searching, but a
sophisticated method of replacing as well. In a replacement string, the
following substitutions are made before any text replacement occurs:
1. Each occurrence of the character & is replaced with whatever was last
matched by the entire pattern.
2. Each occurrence of a string of the form \n, where n is one of the digits
1-9, is replaced by whatever was last matched by the sub-pattern beginning with
the nth occurrence of (.
3. Each occurrence of a string of the form \p, where p is other than one of
the digits 1-9, is replaced by p.
This allows you to not only be able to search for a string satisfying a complex
set of conditions, but also to be able to do a subsequent replacement that
varies depending on the string that is matched. Note that this does not take
into account escape sequences, such as \t, \r, \n, \\, etc. Suppose that you
have written a program that is to become a Macintosh application (i.e., it uses
the Macintosh ToolBox instead of stdio for the user interface). Suppose also
that you have discovered that you have forgotten to put a \p at the beginning of
your string constants, so that your program is trying to pass C strings instead
of Pascal strings to the Toolbox (which only knows how to deal with Pascal
strings). You can easily change all your C strings to Pascal strings by
specifying "(.*)" as the search pattern and "\\p\1" as the replacement string.
Suppose you decided to reverse the two arguments of the function "foo". You
might try the pattern foo\(([^,]*),([^)]*)\) as the search pattern and foo(\2,
\1) as the replacement pattern. How does the search pattern work?
Let's assume we're trying to match some text that looks like foo(1,*bar)
foo\(([^,]*),([^)]*)\) matches foo(1,*bar)
Since ([^,]*) matched 1 and ([^)]*) matched *bar, the two arguments to foo, the
replacement pattern foo(\2, \1) will result in foo(*bar, 1)
This, unfortunately, won't work in the case of foo(1,(*bar)+2), since ([^)]*)
will match only up to the first right parenthesis, leaving +2) unmatched. If
we're sure that all calls to foo end with a semicolon, however, we can change
our pattern to foo\(([^,]*),([^;]*)\);. In this pattern, instead of trying to
match the second argument by matching everything up to the first right
parenthesis, we match everything up to the ); which terminates the invocation of
foo.
In this example we showed how to analyze a grep pattern by examining
sub-patterns. This is a good way of figuring out how to build a pattern as well.
Grep can be thought of as a small and rather cryptic programming language, with
each pattern a program and sub-pattern a statement in this language. If you try
to create a grep pattern by testing a small sub-pattern, then adding and testing
additional sub-patterns until the complete pattern is built, you may find
building complex grep patterns not nearly as daunting as you first thought.
---
Preferences Dialog
To bring up the Preferences dialog, choose “Preferences…” from the Edit menu, or
double-click on your BBEdit Prefs file. (This may not be convenient, since the
BBEdit Prefs file usually resides somewhere within the System Folder.)
The popup menu next to the “Preferences” text determines which section of the
preferences you’re looking at. If you click on “Save”, all of the preferences
settings will be saved to the “BBEdit Prefs” file. If you click on “Cancel”,
the existing preferences will be left alone, and any changes you’ve made in the
Preferences settings will be discarded.
--> The “General Preferences” settings affect BBEdit’s overall appearance and
behavior.
• Show Icons in Browsers determines whether the desktop icons of disks,
folders, and documents appear in the browser search windows. See the section
on “Browsers” above for more information.
• MPW Compatible makes BBEdit emulate some aspects of the MPW Shell’s
behavior. If it’s turned on, command-A is used for Select All, command-G for
Find Again, command-H for Find Selection, command-J for Go To Line…, and command
-T for Replace and Find Again. If it’s turned off, these keyboard equivalents
become the same as for older versions of THINK C, with some minor changes:
command-A is Find Again, command-Y is Replace and Find Again, command-T is Find
In Next File, and command-G is Go To Line
The “Startup Action” radio buttons control what BBEdit does when it’s
launched by some means other than double-clicking on a BBEdit document, or by
dragging and dropping some item onto BBEdit itself (under System 7).
• If Nothing is selected, BBEdit will take no action at startup. This is
handy if BBEdit regularly gets launched into the background, or is launched by
some scripting utility which will then start feeding commands to BBEdit
directly.
• New Window causes BBEdit to bring up a new untitled window, as if the “New”
command on the File menu had been chosen.
• Open causes BBEdit to bring up an “Open…” dialog, as if the “Open…” command
on the File menu had been chosen.
• Open Several causes BBEdit to bring up the “Open Several…” dialog, as if
that command had been chosen.
• New Browser instructs BBEdit to bring up a new browser upon starting up.
--> The “Windows” preferences control BBEdit’s window behavior.
• Delay When Scrolling makes BBEdit wait a tenth of a second when you
click in the arrows of a scrollbar before scrolling the text in a document
window. This is most useful under System 6 on faster machines; often several
lines will go by before your reflexes allow you to let go of the mouse button.
System 7 offers a “scrolling throttle”, so this setting may be turned off.
• Show Status Bar causes the status bar to be visible within all editing
windows. (See “Editing Text With BBEdit” for a description of the status bar.)
This option is on by default; you can turn it off if you have a small screen and
screen “real estate” is at a premium.
• Show Philip Bar draws a vertical gray line in the status bar at the
point where the visible editing area ends on a 9-inch “classic” screen. See
above for more details.
• Show Tab Stops places tick marks in the status bar to indicate the
position of tab stops in each editing window. This option is dimmed if “Show
Status Bar” is turned off.
• Show Line Numbers places line numbers along the left edge of each
editing window.
• Show Cursor Position places the cursor-position display at the lower
left corner of each editing window; this display shows the position of the
insertion point, or the last-changed end of the selection range.
--> The “Editor” preferences control BBEdit’s editing and keyboard behavior.
• The “Default Font” button sets the font which will be used to display the
text in newly created windows, and for documents which have no saved state
information.
• If Auto-Indent is turned on, BBEdit will indent to the start of the
preceding line whenever you type the “Return” key on the keyboard. This is
useful for programmers and for reverse-indenting text. It may be less convenient
if you’re using BBEdit for composing prose.
• Wrap While Typing: generally, BBEdit does not automatically wrap text as
you type it in, which means the text may scroll horizontally. Selecting this
option tells BBEdit to enter carriage returns at the end of each line, according
to the current “Wrap…” settings.
• If Balance While Typing is turned on, BBEdit will flash matching
parentheses, curly braces, and brackets as you type them.
• Smart Quotes is used to determine the default value of the Smart Quotes
setting for newly created windows and for documents saved with state information
other than “BBEdit”.
• Show Invisibles is used to reveal or conceal characters that normally
remain invisible on the screen, such as tabs (“Δ”), carriage returns (“¬”) and
ASCII control characters. When activated, each invisible character will be
displayed as an inverted question mark (“¿”), except as noted.
• Ordinarily, actions such as Entab, Detab, Zap Gremlins, and Replace All are
not undoable, and BBEdit will alert you if you are about to perform a
non-undoable action. If you aren’t concerned about being able to undo these
actions, and don’t want BBEdit to alert you, turn on the ‘No “Can’t Undo”
Alerts’ check box, and BBEdit will not alert you of these actions.
• Exchange Command and Option reverses the meaning of the Command and
Option keys when used with the left and right arrow keys. See “Editing Text with
BBEdit” for more details.
• Intelligent Cut & Paste works similar to many word processors; when
activated, it allows you to double click on a word and cut it without having to
worry about removing the extra space that was before or after that word. When
you paste a word next to another word, this option tells BBEdit to insert a
space between the word being pasted and the word which is already there, if
necessary.
Note: Intelligent Cut & Paste is particularly useful for editing human language
documents, but less so for computer language documents. It is generally
advisable to deactivate this feature when editing source code.
• If Use Keypad for Cursor Control is checked, the keys on the numeric
keypad (on keyboards that have them) will move the cursor. See “Editing Text
With BBEdit” for more details.
--> The “Printing” settings provide the default print settings for new
windows and for documents which have saved state information other than BBEdit’s.
These settings correspond to the same settings on the “Options…” dialog which
can be brought up from the Print… dialog.
--> The “Search Preferences” settings provide the defaults for text searching
and multi-file searching. The options in this dialog correspond to their
counterparts in the Find… and the Multi-File Search Options dialog.
The “Start From…” button sets the default starting directory for Directory
Scan multi-file searches.
--> The “Filing Preferences” settings in this part of the Preference dialog
control the default settings for the Open… and Open Several… dialogs. The
“Default Saved State” popup menu determines what state information will be saved
by default when you choose “Save As…” for a new window or for a file with no
saved state information. If “Auto-Backup” is checked, a backup will
automatically be made of afile every time it is saved.
--> The “State Preferences” settings control what parts of a file’s saved state
are honored whenever a file with saved state information is opened. In some
cases, it may be desirable to ignore one of these aspects of the saved state. If
the “Leave Room for Finder Icons” is checked, BBEdit will make certain that
there’s enough space below and to the right of any window so that icons on the
desktop can be seen when you’re running under MultiFinder or System 7.
--> The “Wrapping Preferences” settings are the default settings for the Wrap…
dialog.
--> The “Zapping Preferences” settings are the default settings for the “Zap
Gremlins…” dialog.
--> The “File Types” section of the Preferences allows you to modify the list of
file creators that appears in the “File Creator” popup menu of the “Save As…,
Options…” dialog box.
To add a new application’s file creator to the list, click the “Add…” button,
and choose the application. To change an application’s creator signature, click
on an application name in the list, enter a new four-letter code in the text
field next to “Creator…”, and click the “Change” button. You can use the “Set…”
button to pick an application and enter its creator code in the text field for
you. To remove an application creator from the list, click on an application
name, and click the “Delete” button.
The creators for “BBEdit” and “Generic Text File” are built into BBEdit and
cannot be changed or deleted.
--> The “Grep Patterns” of the Preferences dialog allows you to modify the list
of regular expressions which appears in the popup menu next to the “Grep” check
box in the “Find…” dialog. The scrolling list box shows the names of the
installed patterns. When you click on one, the text fields below the list will
be filled in with its name, search pattern, and replace pattern. You can change
any of these text fields, and click “Change” to replace the selected pattern
with the changed one. You can also enter new information in the text fields and
click “Add” to add a new pattern, or select a pattern and click “Delete” to
remove it from the list.
Note: You can install a pattern with an empty replace pattern, which is useful
just for locating text which matches a particular regular expression.
--> Use the “Search Folder Preferences” dialog box to define your most commonly
used starting directories for multi-file searching.
Use the “Add…” button to enter a new search folder to the list. The resulting
list of search paths is made available in a popup menu in the “Multi-File
Search Options” for the “Find…” command (under the Search menu).
--> The controls in the “External Services” section of the Preferences determine
what applications and utilities BBEdit will use. Certain portions of BBEdit’s
functionality rely on external services being available.
Activate the checkboxes next to each service that you plan to use.
Note: Any changes you make in this section will not take effect until the next
time you launch BBEdit.
Note: All of the check boxes are checked, by default. However, BBEdit will
examine the desktop database of each mounted volume to determine whether a given
service is available. If a service isn’t available, the corresponding check box
will be un-checked. If a service becomes available at some later point in time,
you’ll need to manually turn the check box back on in this section.
If any of the applications you’ll be using may be residing on a fileserver
volume, check the “Check Remote Volumes” check box. Otherwise, turning it
off will improve BBEdit’s startup performance to some degree.
The “Preferred Toolbox Reference” radio buttons determine which service
BBEdit will use to support the insertion of Toolbox call templates and Toolbox
name lookups. Make sure the check box corresponding your desired Toolbox
reference (“THINK Reference” or “ToolServer”) is checked.
---
Using BBEdit With THINK C 6.0
In order to use BBEdit as an external editor for THINK C 6.0, you’ll need
System 7.0 or later.
--> Configuring the THINK Project Manager
To instruct the THINK Project Manager to use BBEdit as its external editor:
• Create an alias to BBEdit, copy it to the “Tools” folder in the same
directory as the THINK Project Manager application, and name it “Editor”.
• Launch the THINK Project Manager (if it isn’t already running), and choose
“THINK Project Manager…” from the Options sub-menu, under the Edit menu. The
THINK Project Manager will present its options dialog.
• Choose “Editor” from the pop-up menu in this dialog. You’ll see the
options screen displayed.
• If the “Use external editor” check-box doesn’t have an “X” in it, click on
it.
• Click the “OK” button in the options dialog.
• Quit the THINK Project Manager.
To set up BBEdit to work with the THINK Project Manager, perform the following
steps:
• Launch BBEdit.
• Choose “Preferences…” from the Edit menu.
• Choose “External Services” from the pop-up menu. You’ll see the “External
Services” preferences screen displayed.
• Make sure the “THINK C” check-box has an “X” in it. If it doesn’t, click on
it. (You’ll need to quit BBEdit and re-launch it if you do this.)
• Click the “Save” button.
• Quit BBEdit.
--> Using BBEdit with the THINK Project Manager
Once you have set up both BBEdit and the THINK Project Manager, you’ll notice
the following behavior:
• There will be a menu in the menu bar with the THINK Project Manager icon.
The commands on this menu can be used to bring the THINK Project Manager to the
front (and launch it if necessary), and to control the THINK Project Manager to
a certain extent.
• Whenever the THINK Project Manager needs to open an existing text file, it
will use BBEdit to open that file; if BBEdit’s not already running, the THINK
Project Manager will launch it.
• If a compilation error occurs, BBEdit will come to the front, and the line
containing the error will be highlighted. BBEdit will also present an alert box
containing the error message, and may also open the “Compile Errors” browser
window.
• If you edit a text file in BBEdit, the THINK Project Manager will be aware
of the changes without any additional steps on your part, whether or not you
save the file.
• If the front editing window is in the project that’s currently open in the
THINK Project Manager, you can get a pop-up menu of the files included by that
source file by holding down the Option key and clicking on the window’s title
bar. Choosing a file from this menu will open it.
Note: The pop-up menus will only appear if the source file you open has been
successfully compiled at least once.
• Whenever you open a text file, BBEdit will determine whether the file
you’re opening is part of the project that’s currently open in the THINK Project
Manager. If it is, you can use commands on the THINK Project Manager menu to
process that file and the project that uses it. See “Controlling the THINK
Project Manager”, below, for more information.
• If the front editing window does not belong to the project that’s currently
open, only the “Bring to Front”, “Add…” and “Add & Compile commands from the
THINK Project Manager menu are available.
• If you close the currently open project via the THINK Project Manager’s
“Close Project” command, BBEdit will determine which, if any, of the
currently open windows belong to that project. If there are any, you’ll be asked
if you wish to save any unsaved windows, and all documents belonging to that
project will be closed.
• If you switch projects, either by using the THINK Project Manager’s
“Switch Project” hierarchical menu, or by double-clicking on a project in
the Finder when another one is open in the THINK Project Manager, BBEdit will
present an alert.
In this case, BBEdit has no way of notifying the THINK Project Manager of files
that have been changed, so you should use the Project Manager’s “Make…”
command to check for files that have been modified.
-->Controlling the THINK Project Manager with BBEdit
When BBEdit is set up to control the THINK Project Manager, the following
commands are available from the THINK Project Manager menu:
• Bring To Front. This command brings the THINK Project Manager application
to the foreground, launching it if necessary. If it’s not already running,
BBEdit will launch it.
• Compile. When the front window belongs to the project that’s currently open
in the THINK Project Manager, this command will compile the source in the front
window.
• Check Syntax. When the front window belongs to the project that’s currently
open in the THINK Project Manager, this command will check the syntax of the
source in the front window.
• Add. If the front editing window has been saved on disk, and it isn’t part
of the currently open project, this command will add the file represented in the
front window to the current project.
• Add & Compile. This command behaves the same as “Add”, and will also
compile the file after adding it to the project.
• Disassemble. When the front window belongs to the project that’s currently
open in the THINK Project Manager, this command will process the source in the
front window, and place the disassembly output in a new, untitled editing
window.
• Preprocess. When the front window belongs to the project that’s currently
open in the THINK Project Manager, this command will process the source in the
front window, and place the preprocessor output in a new, untitled editing
window.
• Precompile… When the front window belongs to the project that’s currently
open in the THINK Project Manager, this command will execute the Project
Manager’s “Precompile…” command for the front editing window.
• Bring Up To Date will instruct the THINK Project Manager to check for any
modified files in the project, and recompile and reload them as necessary.
• Make… brings up the following dialog:
• If “Compile All Source Files” is checked, BBEdit will instruct the THINK
Project Manager to recompile all source files in the project, regardless of
whether they’ve been changed or not.
• If “Load All Libraries” is checked, BBEdit will instruct the THINK Project
Manager to reload all libraries (projects, library files, and .O files) in the
project, regardless of whether they have been changed or not.
• If “Use Disk” is checked, the THINK Project Manager will examine the files
on disk to determine whether they need to be recompiled or reloaded; if “Quick
Scan” is checked, the THINK Project Manager will not attempt to locate the
files, but will instead use the last-remembered location.
• Run will run the currently open project, if it’s an application or runnable
desk accessory.
When issuing commands to the THINK Project Manager, BBEdit will honor the
settings of the “Confirm auto-make” and “Use Debugger” settings for the
currently open project. To change these settings, bring the THINK Project
Manager to the front and use the appropriate commands.
--> “Open Selection” and the THINK Project Manager
If you choose “Open Selection” and the file you are editing belongs to the
project that’s currently open, BBEdit will communicate with the THINK Project
Manager, and if the file name you selected is included with an “#include”
directive, BBEdit will behave as the THINK Project Manager does, and open the
file that’s specified by the #include directive.
--> Miscellaneous Issues and Pitfalls
Because of the nature of the external editor interface in THINK C 6.0, it’s not
possible for an external editor to be completely integrated with the THINK
environment. You’ll notice the following shortcomings; future versions of both
BBEdit and the THINK Project Manager should address them:
• There is no way for an external editor to support the “Debug” command, in
which you can make a selection in your editing window visible in the THINK
Debugger’s “Source” window. In order to view a file that’s not currently visible
in the source window, switch to the THINK Project Manager, bring the project
window to the front, click once on the file that you wish to make visible, and
choose “Debug” from the Project Manager’s Source menu (or hit Command-I). The
THINK Debugger will use the correct source text, even if you have the file open
and unsaved within BBEdit.
• The THINK Project Manager is not able to accept requests from an external
editor to process a source file that’s not in the currently open project. This
means that the “Compile”, “Check Syntax”, “Preprocess”, “Disassemble”, and
“Precompile” commands on the THINK Project Manager menu can only be used with an
open window which belongs to the currently open project. In order to use one of
these commands on a source file that isn’t in the current project, you’ll need
to open the source file in the Project Manager and use the appropriate command
on the Source menu to process the file.
Note: To open a file in the Project Manager, you’ll need to turn off the “Use
External Editor” switch in the Project Manager, and choose “Open…” from the
Project Manager’s File menu. Turn the “Use External Editor” switch back on to
resume the use of BBEdit as the external editor.
• Currently, BBEdit does not track markers, data view information, or
debugger breakpoints that may be present in the file you’re editing. Because of
this, non-trivial changes to a source file will cause the THINK Debugger to
place breakpoints in locations other than those that were saved at the last
debugging session, and some data-view contexts may be lost. Also, markers will
lose synchronization with the text.
---
Using BBEdit with ToolServer
BBEdit is one of a few applications which support Apple's ToolServer™. This
functionality requires system 7.0 or later, and enough RAM to run both BBEdit
and ToolServer at the same time.
--> About ToolServer
ToolServer is the MPW “back end”; that is, the part of MPW which can run
scripts and MPW tools. None of MPW's editing commands are available, but
nevertheless, ToolServer is an excellent tool for performing MPW-based tasks.
For more on the gestalt of ToolServer, read the documentation that comes with
it..
--> BBEdit and ToolServer
To communicate effectively with ToolServer, BBEdit uses a few custom scripts and
tools of its own.
• BBEditStartup. This script establishes the link between BBEdit and
ToolServer. It also will execute any scripts in the same folder as ToolServer
whose names are BBEditStartup•<anything>. This is analogous to the MPW Shell's
UserStartup• functionality. This file is executed whenever you start up
ToolServer from within BBEdit. You should avoid modifying this script. If you
have customizations, create a BBEditStartup• file.
• BBEditShutDown. This script breaks the link between BBEdit and ToolServer.
It will also execute any BBEditShutDown• files. You should avoid modifying this
script. If you have customizations, create a BBEditShutdown file. This script
is executed when you turn off “Use ToolServer” or quit BBEdit after you've
turned on “Use ToolServer”.
• BBEditStartup•411. This script contains some of the contents of the
UserStartup•Help file supplied with MPW's “411” Toolbox reference set. It also
contains additional commands necessary for BBEdit's support of 411 to work
correctly. You should only install this file if you are also installing the 411
system. Otherwise, leave it out of the MPW folder.
To enhance its support of ToolServer, BBEdit also comes with customized versions
of the File and Line commands. Within ToolServer, File and Line are not
ordinarily available, but with these scripts, you can use File and Line from
within BBEdit. These commands are particularly handy to have when working with
compiler error output.
The “RBBEdit” tool is essential to BBEdit’s support of ToolServer. Without this
tool, none of BBEdit’s ToolServer support will work correctly. You should copy
this tool to the Tools folder which is in the same directory as ToolServer (and
as MPW, if it’s installed).
To install these items, simply drag them to their appropriate places as
indicated by the name of the folder they're in.
-->Using ToolServer
Once BBEdit is running, you may use ToolServer by choosing “Use ToolServer from
the MPW menu. Once ToolServer is running, a check mark will be placed next to
the “Use ToolServer” command; choose “Use ToolServer” again to shut down
ToolServer.
After connecting to ToolServer, BBEdit will open the “ToolServer Worksheet
window. In this window, you can enter MPW shell commands just as you would when
using the MPW Shell itself. To send a command to ToolServer, place the insertion
point on the same line as the command you wish to execute, or select the
commands you want to execute, and hit the Enter key or choose “Send Command”
from the MPW menu.
To execute a file full of commands (for example, the output of a makefile), open
the file, and choose “Execute Commands” from the MPW menu. Each command will be
selected and executed in sequence. This functionality is analogous to MPW's
“DoIt” command.
--> BBEdit and 411
To use 411 from within BBEdit, make sure that all of the BBEdit support tools
and scripts are correctly installed, as are the necessary tools and help files
for 411. Choose “Preferences…” from the Edit menu, and in the “External
Services” section, select ‘MPW “411”’ as the preferred Toolbox reference. Start
ToolServer via the “Use ToolServer” command on the MPW menu, and you’ll be able
use the 411 system as a reference system.
To look up a Toolbox symbol, select it in any editing window (including the
ToolServer Worksheet or a browser window) and choose “Toolbox Lookup from the
Search menu (or type Command-minus). If the symbol is found in the 411 database,
a “Help” window will be opened, and the reference information for that symbol
will be displayed.
To paste a call template for a Toolbox function, select the function's name and
choose “Toolbox Call Template” from the “Insert” sub-menu on the Edit menu (or
type Command-M). The selected name will be replaced with a call template of that
function.
If you choose “Toolbox Lookup” or “Toolbox Call Template” with no selection, a
dialog box will prompt you for the Toolbox symbol to be looked up or templated.
Type in a symbol and click the “OK” button to proceed, or the “Cancel” button to
do nothing.
--> ToolServer Tools
By means of the “ToolServer Tools” folder, you can make your most commonly-used
MPW tools and scripts available from the MPW menu in BBEdit.
When BBEdit starts up, it looks for a folder called “ToolServer Tools” in the
same folder as the BBEdit application. If this folder is present, BBEdit scans
the folder and adds the items in that folder to the menu. For an item to be
available, it must be either an MPW tool or a text file (type ‘TEXT’), and must
be in the main level of the “ToolServer Tools” folder. Files that aren’t text
files or aren’t MPW tools won’t be available from the MPW menu, nor will files
that are in folders within the “ToolServer Tools” folder.
You can add or remove tools and scripts while BBEdit is running; BBEdit will
automatically update the list of tools as necessary.
An item in the ToolServer Tools folder may be either a file or an alias; in the
case of the tools supplied with MPW or ToolServer, you may find it desirable to
make an alias to a tool or script, rather than to copy the tool to the
ToolServer Tools folder.
--> Naming Conventions and Behavior
BBEdit behaves in a number of possible ways when you choose a tool or script
from the MPW menu:
• If the item corresponds to an MPW tool, and that tool supports Commando,
then BBEdit will pull ToolServer to the front and bring up the Commando dialog
for that tool.
Note: If you’re using a ToolServer on a remote machine, you’ll get a message
from BBEdit that Commando isn’t supported for remote ToolServers.
• If the item corresponds to an MPW tool that does not support Commando,
BBEdit will bring up a dialog in which you can enter the arguments for the
desired tool.
You can enter carriage returns in the argument text, if you desire; use the
Enter key as a shortcut for the Run button.
• If the item corresponds to a script, and you’ve ended the name of the
script or the alias to the script with an ellipsis (“…”, by typing
option-semicolon), BBEdit will bring up the dialog for entering arguments, as
shown above.
• If the item corresponds to a script with a ‘cmdo’ resource in it, then
BBEdit will pull ToolServer to the front and bring up the Commando dialog for
that script.
Note: If you’re using a ToolServer on a remote machine, you’ll get a message
from BBEdit that Commando isn’t supported for remote ToolServers.
• If the item corresponds to a script that doesn’t have an ellipsis at the
end of its name, and which doesn’t have a ‘cmdo’ resource in it, BBEdit will
simply execute that script when you choose its name from the ToolServer menu.
---
BBEdit and XTND
BBEdit supports the Claris XTND translator mechanism for importing and exporting
files from and to other word-processor formats. Because of space and download
time considerations, the BBEdit demo package does not include the Claris XTND
system and translators.